'use strict';
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	const db = uniCloud.database({})
	const shop = db.collection("db_shop_addr")
	//返回数据给客户端
	console.log(event)
	if (event.aflat) {
		await shop.where({
			aflat: true
		}).update({
			aflat: false
		})
	}
	if (event.type == 0) {
		return await shop.where({
			_id: event.aid
		}).get()
	} else {
		return await shop.where({
			_id: event.aid
		}).update({
			aname: event.aname,
			aphone: event.aphone,
			aaddr1: event.aaddr1,
			aaddr2: event.aaddr2,
			aflat: event.aflat
		})
	}


	//返回数据给客户端
};